#pragma once

#include "EngineObject.h"
#include "ShaderParamTable.h"
#include "AutoShaderParam.h"

namespace DreamEngine
{
enum ShaderProfile
{
	SP_UNKNOWN      = 0,

	SP_VS_2_0       = 1,
	SP_VS_3_0       = 2,

	SP_PS_2_0       = 10,
	SP_PS_3_0       = 11,
};

enum ShaderType
{
	ST_UNKOWN	= 0,
	ST_FRAGMENT = 1,
	ST_VERTEX	= 2,
};

static CString ProfileToString(ShaderProfile profile)
{
	switch(profile)
	{
	case  SP_PS_2_0:
		return "ps_2_0";

	case SP_PS_3_0:
		return "ps_3_0";

	case SP_VS_2_0:
		return "vs_2_0";

	case SP_VS_3_0:
		return "vs_3_0";

	default: return "unknown";
	}
}

class _EngineExport CGpuProgram : public CEngineObject
{
public:

	CGpuProgram(ShaderProfile profile);
	virtual ~CGpuProgram(void);

	virtual Error		Initialize(const CString& fileName, const CString& enterFun);
	virtual void		Destory(void);

	CShaderParamTable*	GetShaderParamTable(void)const	{return m_pShaderParamTable;}
	ShaderProfile		GetProfile(void)const			{return m_shaderProfile;}
	CString				GetProfileAsString(void)		{return ProfileToString(m_shaderProfile);}
	ShaderType			GetType()const;

	virtual void		Update(void);

protected:

	ShaderProfile		m_shaderProfile;
	CShaderParamTable*	m_pShaderParamTable;

protected:

	virtual Error		LoadFromFile(const CString& fileName, const CString& enterFun)=0;
	virtual Error		CreateParamTable(void)=0;
	virtual Error		CreateShader(void)=0;

	virtual void		UpdateAutoParams(void)=0;
	virtual void		UpdateParams(void)=0;
};

}


